<template>
	<view class="content">
		<view class="titleStyle">课程大纲</view>
		<view v-for="(item,index) in chapters" :key="index">
			<view class="bigChapterStyle">
				{{item.bigChapter}}
			</view>
			<view v-for="(smallitem,id) in item.children" :key="id">
				<view class="smallChapterStyle">
					{{smallitem.smallChapter}}
				</view>
			</view>
		</view>
		<view style="height: 110rpx;"></view>
	</view>
</template>

<script>
	//getCourseDetailsChapter
	import {
		getCourseDetailsChapter
	} from '@/api/modules/course.js'
	export default {
		props: {
			courseID: {
				type: String,
				default: 'Add'
			}
		},
		data() {
			return {
				itemList: [],
/* 				chapters: [{
						"bigChapter": "第1章 软件项目管理导论",
						"children": [{
								"smallChapter": "第1节 软件项目管理概述",
								"children": [{
										"videoName": "1-项目管理的发展",
										"id": "3"
									},
									{
										"videoName": "2-什么是项目",
										"id": "4"
									},
									{
										"videoName": "3-测试视频",
										"id": "e97d0503-6173-4f8e-8216-deb2ffbfbfbb"
									},
									{
										"videoName": "4-1",
										"id": "2e7aa55a-93db-4b0f-bb9c-dfc30c3636ef"
									},
									{
										"videoName": "5-2",
										"id": "0c6410ac-7deb-4569-a0fa-60f640de621c"
									},
									{
										"videoName": "6-3",
										"id": "85d95814-3f4c-4773-8188-a9d0817e48a3"
									}
								],
								"id": "2"
							},
							{
								"smallChapter": "第2节 软件项目分类",
								"children": [{
									"videoName": "1-软件项目分类",
									"id": "6"
								}],
								"id": "5"
							},
							{
								"smallChapter": "第3节 软件项目管理第3节",
								"id": "d12cc88e-3b24-402c-8dd1-15359c1d698c"
							},
							{
								"smallChapter": "第4节 软件项目管理第4节",
								"id": "f4b3c536-f1a5-4dac-b598-658fbba8ad2a"
							},
							{
								"smallChapter": "第5节 软件项目管理第5节",
								"id": "e8960a10-cb5d-4450-817e-0a5cdee18f2f"
							}
						],
						"id": "1"
					},
					{
						"bigChapter": "第2章 组织平台",
						"children": [{
								"smallChapter": "第1节 软件项目管理概述",
								"children": [{
										"videoName": "1-项目管理的发展",
										"id": "3"
									},
									{
										"videoName": "2-什么是项目",
										"id": "4"
									},
									{
										"videoName": "3-测试视频",
										"id": "e97d0503-6173-4f8e-8216-deb2ffbfbfbb"
									},
									{
										"videoName": "4-1",
										"id": "2e7aa55a-93db-4b0f-bb9c-dfc30c3636ef"
									},
									{
										"videoName": "5-2",
										"id": "0c6410ac-7deb-4569-a0fa-60f640de621c"
									},
									{
										"videoName": "6-3",
										"id": "85d95814-3f4c-4773-8188-a9d0817e48a3"
									}
								],
								"id": "2"
							},
							{
								"smallChapter": "第2节 软件项目分类",
								"children": [{
									"videoName": "1-软件项目分类",
									"id": "6"
								}],
								"id": "5"
							},
							{
								"smallChapter": "第3节 软件项目管理第3节",
								"id": "d12cc88e-3b24-402c-8dd1-15359c1d698c"
							},
							{
								"smallChapter": "第4节 软件项目管理第4节",
								"id": "f4b3c536-f1a5-4dac-b598-658fbba8ad2a"
							},
							{
								"smallChapter": "第5节 软件项目管理第5节",
								"id": "e8960a10-cb5d-4450-817e-0a5cdee18f2f"
							}
						],
						"id": "7"
					},
					{
						"bigChapter": "第3章 软件项目管理架构",
						"children": [{
								"smallChapter": "第1节 软件项目管理概述",
								"children": [{
										"videoName": "1-项目管理的发展",
										"id": "3"
									},
									{
										"videoName": "2-什么是项目",
										"id": "4"
									},
									{
										"videoName": "3-测试视频",
										"id": "e97d0503-6173-4f8e-8216-deb2ffbfbfbb"
									},
									{
										"videoName": "4-1",
										"id": "2e7aa55a-93db-4b0f-bb9c-dfc30c3636ef"
									},
									{
										"videoName": "5-2",
										"id": "0c6410ac-7deb-4569-a0fa-60f640de621c"
									},
									{
										"videoName": "6-3",
										"id": "85d95814-3f4c-4773-8188-a9d0817e48a3"
									}
								],
								"id": "2"
							},
							{
								"smallChapter": "第2节 软件项目分类",
								"children": [{
									"videoName": "1-软件项目分类",
									"id": "6"
								}],
								"id": "5"
							},
							{
								"smallChapter": "第3节 软件项目管理第3节",
								"id": "d12cc88e-3b24-402c-8dd1-15359c1d698c"
							},
							{
								"smallChapter": "第4节 软件项目管理第4节",
								"id": "f4b3c536-f1a5-4dac-b598-658fbba8ad2a"
							},
							{
								"smallChapter": "第5节 软件项目管理第5节",
								"id": "e8960a10-cb5d-4450-817e-0a5cdee18f2f"
							}
						],
						"id": "26f722a2-c29b-4f0c-b0ef-8324d0d76f9b"
					},
					{
						"bigChapter": "第4章 软件项目管理规则",
						"children": [{
								"smallChapter": "第1节 软件项目管理概述",
								"children": [{
										"videoName": "1-项目管理的发展",
										"id": "3"
									},
									{
										"videoName": "2-什么是项目",
										"id": "4"
									},
									{
										"videoName": "3-测试视频",
										"id": "e97d0503-6173-4f8e-8216-deb2ffbfbfbb"
									},
									{
										"videoName": "4-1",
										"id": "2e7aa55a-93db-4b0f-bb9c-dfc30c3636ef"
									},
									{
										"videoName": "5-2",
										"id": "0c6410ac-7deb-4569-a0fa-60f640de621c"
									},
									{
										"videoName": "6-3",
										"id": "85d95814-3f4c-4773-8188-a9d0817e48a3"
									}
								],
								"id": "2"
							},
							{
								"smallChapter": "第2节 软件项目分类",
								"children": [{
									"videoName": "1-软件项目分类",
									"id": "6"
								}],
								"id": "5"
							},
							{
								"smallChapter": "第3节 软件项目管理第3节",
								"id": "d12cc88e-3b24-402c-8dd1-15359c1d698c"
							},
							{
								"smallChapter": "第4节 软件项目管理第4节",
								"id": "f4b3c536-f1a5-4dac-b598-658fbba8ad2a"
							},
							{
								"smallChapter": "第5节 软件项目管理第5节",
								"id": "e8960a10-cb5d-4450-817e-0a5cdee18f2f"
							}
						],
						"id": "01c42693-9ee4-482a-a7ca-15c78350c3c2"
					}
				], */
				chapters:[],
			}
		},
		methods: {

		},
		props: {
			courseID: {
				type: String,
				default: 'Add'
			}
		},
		/* mounted(){
			let data = {
					courseID: 1
				}
					
				let that = this;
				
				getCourseDetailsChapter(data)
					.then(resp => {
						that.chapters = JSON.parse(resp.data)
					
						// that.$nextTick(() => {
						// 	that.$refs.collapseInit1.init()
						// })
						//console.log(JSON.parse(resp.data))
					})
					.catch(resp => {})
			
		}, */
		watch: {
		
			courseID: {
				immediate: true, // 这句重要
				handler(val) {
					// 继续要处理的事件
					// console.log("获取课程章节")
					// console.log(val)
		
					// 获取课程ID对应的章节列表
					let data = {
						courseID: this.courseID
					}
		
					let that = this;
					
					that.courseInfoID = val;
		
					getCourseDetailsChapter(data)
						.then(resp => {
							that.chapters = JSON.parse(resp.data)
		
							// that.$nextTick(() => {
							// 	that.$refs.collapseInit1.init()
							// })
							//console.log(JSON.parse(resp.data))
						})
						.catch(resp => {})
				}
			}
		
		}
	}
</script>

<style>
	.content {
		width: 750rpx;
		padding-left: 30rpx;
		padding-right: 30rpx;
	}

	.titleStyle {
		margin-top: 30rpx;
		font-size: 40rpx;
		font-weight: bold;
	}

	.bigChapterStyle {
		margin-top: 30rpx;
		font-size: 45rpx;
	}

	.smallChapterStyle {
		margin-top: 10rpx;
		margin-left: 40rpx;
		font-size: 40rpx;
		color: #999999
	}
</style>
